//
//  nightNavViewController.m
//  soccer
//
//  Created by 上官千城 on 15/9/2.
//  Copyright (c) 2015年 上官千城. All rights reserved.
//

#import "OBaseNavViewController.h"

@interface OBaseNavViewController ()

@end

@implementation OBaseNavViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    
    NSUserDefaults *userDefaults = [NSUserDefaults standardUserDefaults];
    
    if ([@"on" isEqualToString:[userDefaults objectForKey:@"isNight"]]) {
        
        //        夜间模式
        //        [[UINavigationBar appearance] setBackgroundImage:[UIImage imageNamed:@"navigationBlack.png"] forBarMetrics:UIBarMetricsDefault];
        //        self.navigationBar.tintColor = [UIColor colorWithRed:27 / 255.0 green:27 / 255.0 blue:27 / 255.0 alpha:1.0];
        self.navigationBar.barTintColor = [UIColor colorWithRed:27 / 255.0 green:27 / 255.0 blue:27 / 255.0 alpha:1.0];
        [self.navigationBar setTitleTextAttributes:@{NSForegroundColorAttributeName: [UIColor whiteColor],NSFontAttributeName:[UIFont systemFontOfSize:17.0]}];
        
    } else {
        
        self.navigationBar.barTintColor = [UIColor colorWithRed:0 / 255.0 green:186 / 255.0 blue:170 / 255.0 alpha:1.0];
        [self.navigationBar setTitleTextAttributes:@{NSForegroundColorAttributeName: [UIColor blackColor],NSFontAttributeName:[UIFont systemFontOfSize:17.0]}];
        
    }
    
    NSNotificationCenter *notificationCenter = [NSNotificationCenter defaultCenter];
    [notificationCenter addObserver:self selector:@selector(changeNight:) name:@"changeNight" object:nil];
    
    
    

    
    
}



-(void)changeNight:(NSNotification *)notification {
    
    
    NSUserDefaults *userDefaults = [NSUserDefaults standardUserDefaults];
    if ([@"on" isEqualToString:[userDefaults objectForKey:@"isNight"]]) {
        
        self.navigationBar.barTintColor = [UIColor colorWithRed:27 / 255.0 green:27 / 255.0 blue:27 / 255.0 alpha:1.0];
        [self.navigationBar setTitleTextAttributes:@{NSForegroundColorAttributeName: [UIColor whiteColor],NSFontAttributeName:[UIFont systemFontOfSize:17.0]}];
        
    } else {
        self.navigationBar.barTintColor = [UIColor colorWithRed:0 / 255.0 green:186 / 255.0 blue:170 / 255.0 alpha:1.0];
        [self.navigationBar setTitleTextAttributes:@{NSForegroundColorAttributeName: [UIColor blackColor],NSFontAttributeName:[UIFont systemFontOfSize:17.0]}];
    }
    
}



- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
